#include "StackOfInt.h"
#include <vector>

struct StackOfInt::StackImp1
{
    int arr[10];
};

struct StackOfInt::StackImp2
{
    vector<int> v;
};

void StackOfInt::show1()
{
    cout << "the StackImp that uses a fixed-length array of int is showing:" << endl;
    Imp1 = new StackImp1;

    // 赋值
    int len = sizeof(Imp1->arr) / sizeof(Imp1->arr[0]);
    for (int i = 0; i < len; i++)
    {
        Imp1->arr[i] = i + 1;
    }

    // 打印
    for (int i = 0; i < len; i++)
    {
        cout << Imp1->arr[i] << " ";
    }
    cout << endl;
}


void StackOfInt::show2()
{
    cout << "the StackImp that uses a vector<int> is showing:" << endl;
    Imp2 = new StackImp2;

    // 赋值
    for (int i = 0; i < 8; i++)
    {
        Imp2->v.push_back(i+10);
    }

    //打印
    for (vector<int>::iterator it = Imp2->v.begin(); it != Imp2->v.end(); it++)
    {
        cout << *it << " ";
    }
    cout << endl;
}
